#!/bin/bash
cd $(dirname "$0")
cpu=$(cat /proc/cpuinfo | grep processor | wc -l)
if [ "$cpu" != '' ];then
    cpu=$((cpu * 2))
fi
if [ "$cpu" = '0' ];then
    cpu=
fi

date '+%Y-%m-%d %H:%M:%S' >build.log
LANG=POSIX make rebuild -j $cpu 2>&1 | tee -a build.log
date '+%Y-%m-%d %H:%M:%S' >>build.log
echo $(($(date +'%s' -d "$(tail -n1 build.log)") / 60 - $(date +'%s' -d "$(head -n1 build.log)") / 60)) | tee -a build.log
